Skip to content

prevent slice::from_raw_parts from being passed a null pointer#1380

Open
z-erica wants to merge 1 commit into
tectonic-typesetting:masterfrom
z-erica:push-qsrumvxrszzm
Open

prevent slice::from_raw_parts from being passed a null pointer#1380
z-erica wants to merge 1 commit into
tectonic-typesetting:masterfrom
z-erica:push-qsrumvxrszzm

Conversation

@z-erica

@z-erica z-erica commented Jul 10, 2026

Copy link
Copy Markdown

when nfont is zero in a FcFontSet, the fonts field can be a null pointer. this can make the test suite panic:

thread 'trip_test' (7786) panicked at crates/bridge_fontconfig/src/font_set.rs:23:18:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed isize::MAX

This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread caused non-unwinding panic. aborting.

this fix maintains the safety invariant by always returning an empty slice with a lifetime of 'static when the array is empty

when nfont is zero in a FcFontSet, the fonts field can be a null pointer.
this can make the test suite panic:

    thread 'trip_test' (7786) panicked at crates/bridge_fontconfig/src/font_set.rs:23:18:
    unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

    This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    thread caused non-unwinding panic. aborting.

this fix maintains the safety invariant by always returning an empty
slice with a lifetime of 'static when the array is empty
@z-erica z-erica marked this pull request as ready for review July 10, 2026 17:39
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 29.86%. Comparing base (06074a2) to head (c43fc0e).

Files with missing lines Patch % Lines
crates/bridge_fontconfig/src/font_set.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1380      +/-   ##
==========================================
- Coverage   29.86%   29.86%   -0.01%     
==========================================
  Files         273      273              
  Lines      180535   180537       +2     
  Branches   180535   180537       +2     
==========================================
  Hits        53909    53909              
- Misses      54411    54412       +1     
- Partials    72215    72216       +1     
Components Coverage Δ
tectonic 51.35% <ø> (ø)
bridge_core 34.25% <ø> (ø)
bridge_flate 38.82% <ø> (ø)
bridge_fontconfig 95.67% <66.66%> (-0.50%) ⬇️
bridge_freetype2 92.70% <ø> (ø)
bridge_graphite2 42.47% <ø> (ø)
bridge_harfbuzz 82.83% <ø> (ø)
bridge_icu ∅ <ø> (∅)
bridge_png 100.00% <ø> (ø)
bundles 36.15% <ø> (ø)
cfg_support 94.84% <ø> (ø)
dep_support 0.00% <ø> (ø)
docmodel 84.61% <ø> (ø)
engine_bibtex 67.46% <ø> (ø)
engine_spx2html 0.00% <ø> (ø)
engine_xdvipdfmx 64.30% <ø> (ø)
engine_xetex 35.73% <ø> (ø)
errors 47.61% <ø> (ø)
geturl 28.20% <ø> (ø)
io_base 76.11% <ø> (ø)
pdf_io 14.19% <ø> (-0.01%) ⬇️
status_base 81.92% <ø> (ø)
xdv 55.28% <ø> (ø)
xetex_format 23.31% <ø> (ø)
xetex_layout 59.57% <ø> (ø)

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant